<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<meta name="renderer" content="webkit">
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<title>定时任务管理</title>
		<link rel="stylesheet" type="text/css" href="${s.base}/lib/layui/css/layui.css" />
		<link rel="stylesheet" type="text/css" href="${s.base}/css/base/index.css" />
	</head>
	<body class="wrap-container clearfix">
		<div class="column-content-detail padt10" id="tool">
			<div class="search-cont clearfix">
				<div class="operation-btn-cont">
					<!--<button class="layui-btn layui-btn-normal layui-btn-mid deleteBtn"  type="button" data-url="/baseRole/delete"><i class="iconfont marr5">&#xe608;</i>删除</button>-->
					<div class="operright cyt-retract-close hideMenu">
						收起筛选<i class="iconfont">&#xe658;</i>
					</div>
					<div class="operright cyt-retract-open showMenu" style="display: none;">
						展开筛选<i class="iconfont">&#xe936;</i>
					</div>
					<div class="triangle-bottom"></div>
					<div class="triangle-top"></div>
				</div>
				<div class="search-details">
					<form class="layui-form" action="">
						<div class="layui-form-item marb5">
							<div class="layui-inline">
								<label class="layui-form-label w75">任务名称：</label>
								<div class="layui-input-inline">
									<input type="text" name="jobName" id="jobName" placeholder="请输入任务名称" autocomplete="off" class="layui-input">
								</div>
							</div>
							<div class="layui-inline marl8">
								<button class="layui-btn layui-btn-normal" type="button" lay-submit="" lay-filter="seacherBtn">搜索</button>
								<button class="layui-btn layui-btn-normal" type="reset" >重置</button>
							</div>
						</div>
					</form>
				</div>
			</div>
			<div class="layui-form mart10" id="table-list">
				<table id="entityList" lay-filter="entityList" class="cy-list-table"></table>
			</div>
	</div>

	<script type="text/html" id="entityBar">
		<button class="layui-btn cy-btnbg-edit layui-btn-sm" lay-event="run">执行一次</button>
		<button class="layui-btn cy-btnbg-edit layui-btn-sm" lay-event="resumeJob">启动</button>
		<button class="layui-btn layui-btn-danger layui-btn-sm" lay-event="pauseJob">停止</button>
	</script>
	<script src="${s.base}/lib/layui/layui.js" type="text/javascript" charset="utf-8"></script>
	<script src="${s.base}/js/common.js" type="text/javascript" charset="utf-8"></script>
	<script>
        layui.use(['jquery','table','page'],function(){
            var $ = layui.jquery,
            table = layui.table,
            page = layui.page;
            var tableIns=null;
            var url="/baseJob/jsonList";
            var cols=[
                {type: 'checkbox', fixed: 'left'},
                {field: 'jobName', title: '任务名称',width:220,align:'center'},
                {field: 'jobGroup', title: '任务组',width:220,align:'center'},
                {field: 'className', title: '类',align:'center'},
                {field: 'cronExpression', title: '表达式',width:220,align:'center'},
                {field: 'status', title: '状态',width:120,align:'center', sort: true, templet:function(d){
                    if(d.status=="1"){
                        return '<a class="layui-btn layui-btn-warm layui-btn-xs cy-btnbg-normal">暂停</a>';
                    }else {
                        return '<a class="layui-btn layui-btn-xs layui-btn-danger cy-btnbg-grey">正常</a>';
                    }
                }},
                {title: '操作',width:220, templet:'#entityBar',align:"center", fixed: 'right'}
            ];
            tableIns=page.initDate(cols,url);

            //监听行工具事件
            table.on('tool(entityList)', function(obj){
                var layEvent = obj.event,
                    data = obj.data;
                if(layEvent === 'edit'){ //编辑
                    // page.editPopup("/baseRole/getAddOrEdit?id="+data.id,"角色编辑");
                }else if(layEvent === 'run'){ //执行一次
                    page.delete("/baseJob/run", {"id":data.id},"确定执行【"+data.jobName+"】吗？",function (data) {
                        tableIns.reload();
                    });
                }else if(layEvent === 'resumeJob'){ //启动
                    page.delete("/baseJob/resumeJob", {"id":data.id},"确定启动【"+data.jobName+"】吗？",function (data) {
                        tableIns.reload();
                    });
                }else if(layEvent === 'pauseJob'){ //暂停
                    page.delete("/baseJob/pauseJob", {"id":data.id},"确定暂停【"+data.jobName+"】吗？",function (data) {
                        tableIns.reload();
                    });
                }
            });
        });
	</script>
	</body>
</html>